#region Using Directives

using System.Windows;
using Composite.Layout.Configuration;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.UnityExtensions;
using Microsoft.Practices.Unity;

#endregion

namespace LayoutManager.Shell
{
    internal class Bootstrapper : UnityBootstrapper
    {
        protected override IModuleCatalog GetModuleCatalog()
        {
            return new DirectoryModuleCatalog {ModulePath = @"."};
        }

        protected override DependencyObject CreateShell()
        {
            var _Shell = new MainWindow();
            _Shell.Show();

            return _Shell;
        }

        protected override void InitializeModules()
        {
            base.InitializeModules();
            InitializeLayoutManager();
        }

        private void InitializeLayoutManager()
        {
            var layoutManager = LayoutConfigurationManager.LayoutManager;
            layoutManager.Initialize(Container);
            Container.RegisterInstance(layoutManager, new ContainerControlledLifetimeManager());
            //parameterless LoadLayout loads the default Layout into the Shell
            layoutManager.LoadLayout();
        }
    }
}